'  ------------------------------------------------------------
'  view.axs 
'  ------------------------------------------------------------
'  VCS INFO:
'  
'  $Revision:   1.18  $
'  $Date:   08 Jul 1999 17:25:16  $
'  $Author:   shsieh  $
'  $Workfile:   view.axs  $
'  ------------------------------------------------------------
'  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
'  ------------------------------------------------------------

'The way this axs file is loaded is different depended on whether the client browser
'is IE or Netscape.
'For IE, we are simply including it in the client side script.
'For Netscape, we are going through nCompass ScriptActive plug-in, and needs to be
'included via a embed tag.
'Plese see view.asp for for deatil.


public annoSavingWindow
dim isInternetExplorer

Sub VBSNotSupported()
MsgBox "Sorry, this feature is not supported for this type of document.", 0, "FileNET Panagon IDM Web"
end sub


'The following handler gets called whenever the user click on a different document in
'the list.
Sub DocList_Click()
pos1 = InStr(DocList.Text, "(")
pos2 = InStr(DocList.Text, ")   ")
if pos1 = 1 and pos2 > 2 then
    DocID = Mid(DocList.Text, 2, pos2 - 2)
    DocList.Text = DocID
else
    DocID = DocList.Text
end if
FnViewCtrl.WebNavigatorURL = "docnavigate.asp?docid=" + DocID
end sub

'If the user type in a document ID, and hit <enter>.
Sub DocList_KeyDown(KeyCode, Shift)
if KeyCode = 13 then
	'FDS 890310 disable this function because of very difficult to write log
	'DocList_Click
end if
end sub


'If the Zoom Factor is changed
Sub ZoomFactor_Change()
if Len(ZoomFactor.Text) then
    if Len(FnViewCtrl.DocumentID) then
        if FnViewCtrl.IsOperationSupported(3) then  'idmOpCustomZoom
            f = ZoomFactor.Text
            if Right(f, 1) = "%" then
	            f = Left(f, Len(f) - 1)
            end if
            if not IsNumeric(f) then
                MsgBox "Invalid zoom factor.", 0, "FileNET Panagon IDM Web"
                ZoomFactor.Text = ""
            end if
        end if
    end if
end if
end sub

'If the user click on a zoom factor in the list.
Sub ZoomFactor_Click()
if FnViewCtrl.IsOperationSupported(3) then  'idmOpCustomZoom
    f = ZoomFactor.Text
    if Right(f, 1) = "%" then
	    f = Left(f, Len(f) - 1)
    end if
    if IsNumeric(f) then
	    FnViewCtrl.CustomZoom = Int(f) / 100
    end if
end if
end sub
    
'If the user type in a zoom factor, and hit <enter>.
Sub ZoomFactor_KeyDown(KeyCode, Shift)
if KeyCode = 13 then
	ZoomFactor_Click
end if
end sub


'Message box only on error.
sub FnViewCtrl_AnnotationSaveStateChange(state, msg)
	if state = 3 then
		if not (annoSavingWindow is nothing) then
			annoSavingWindow.close
			set annoSavingWindow = nothing
		end if

		MsgBox msg, 0, "FileNET Panagon IDM Web"
	end if
end sub

'Message box only on error
sub FnViewCtrl_AnnotationRetrievalStateChange(PageNumber, state, msg)
	if state = 3 then
		MsgBox msg, 0, "FileNET Panagon IDM Web"
	end if
end sub

'Message box only on error
sub FnViewCtrl_PrintStateChange(PageNumber, state, msg)
	if state = 4 then
		MsgBox msg, 0, "FileNET Panagon IDM Web"
	end if
end sub

'Message box only on error
sub FnViewCtrl_BackgroundRetrievalStateChange(state, msg)
	if state = 3 then
		MsgBox msg, 0, "FileNET Panagon IDM Web"
	end if
end sub

sub FnViewCtrl_DocumentOpen(doc)
if FnViewCtrl.IsOperationSupported(3) then  'idmOpCustomZoom
    On Error Resume Next
    ZoomFactor.Enabled = True
else
    On Error Resume Next
    ZoomFactor.Enabled = False
end if
end sub

sub FnViewCtrl_CustomZoomChange(x, y)
    On Error Resume Next
    ZoomFactor.Text = CStr(CInt(x * 100)) + "%"
end sub


'A routine to parse out document ID and label pairs contained within the HiddenDocList,
'and add them to the document list.
Sub AddDocListItems()
DocIDLabel = HiddenDocList.Value
pos1 = InStr(DocIDLabel, "; ")
if pos1 then
    if Len(DocList.Text) = 0 then
        pos2 = InStr(DocIDLabel, ")   ")
        DocList.Text = Mid(DocIDLabel, 2, pos2 - 2)
    end if
    DocList.AddItem Left(DocIDLabel, pos1 - 1)
    pos1 = pos1 + 2
    pos2 = InStr(pos1, DocIDLabel, "; ")
    While pos2 > 0
        DocList.AddItem Mid(DocIDLabel, pos1, pos2 - pos1)
        pos1 = pos2 + 2
        pos2 = InStr(pos1, DocIDLabel, "; ")
    WEnd
end if
end sub


'Called when the document is loaded
Sub window_onLoad()
if navigator.appName = "Microsoft Internet Explorer" then
	isInternetExplorer = true
else
	isInternetExplorer = false
end if

if isInternetExplorer then
	call AddDocListItems()
	On Error Resume Next
	ZoomFactor.Text = "100%"
	if Err = 0 then
	ZoomFactor.AddItem "100%"
	ZoomFactor.AddItem "75%"
	ZoomFactor.AddItem "50%"
	ZoomFactor.AddItem "25%"
	end if
end if

set annoSavingWindow = nothing
end sub


'Called when document is unloaded
sub window_OnUnload()
if FnViewCtrl.AnnotationsModified then
    'If the annotation has been modified

	button = MsgBox("Save changes to document?", vbYesNo, "FileNET Panagon Web")
	if button = vbYes then
		' IE can put up a new window as non-modal dialog
		if isInternetExplorer then
			set annoSavingWindow = open("savAnnos.htm", "AnnotationSaving", "toolbar=no, directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, width=400, height=10, top=300, left=400")
		else
			' nCompass can't create new window in handler
			top.status = "Saving annotations"
		end if
		dim saveStatus
		saveStatus = FnViewCtrl.Save(3)
		' If there was an error, FnViewCtrl_AnnotationRetrievalStateChange() will put up the box.
		if (saveStatus = 0) then
			if not (annoSavingWindow is nothing) then
				annoSavingWindow.close
				set annoSavingWindow = nothing
			end if
			MsgBox "Annotations Saved", 0, "FileNET Panagon IDM Web"
		end if
	end if
end if
end sub